package concurrensy.producer_consumer;

public class Producer implements Runnable{

	private final RingBuffer buffer;
	private final long timeout;
	
	public Producer(RingBuffer buffer, long timeout){
		this.buffer = buffer;
		this.timeout = timeout;
	}
	
	@Override
	public void run() {
		while(true) {
			buffer.addProduct(new Object());
			try {
				Thread.sleep(timeout);
			} catch (InterruptedException e) {
				e.printStackTrace();
				return;
			}
		}
	}

}
